<extend name="Public/base" />
<block name="body">
<div class="main-title cf">
	<h2>新增模型</h2>
</div>
  <div class="tools">
        <a class="btn" href="javascript:void(0);" data-url="{:U('addfriend')}">新 增</a>
</div>
<div class="data-table">
<div class="data-table table-striped">
<table class="">
    <thead>
        <tr>
			<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
			<th>编号</th>
			<th>网站标题</th>
			<th>网站地址</th>
			<th>是否新窗口打开</th>
			<th>操作</th>
		</tr>
    </thead>
    <tbody>
	<notempty name="friends">
		<volist name="friends" id="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="ids[]" value="{$key}" /></td>
			<td>{$key}</td>
			<td>{$vo.title}</td>
			<td>{$vo.url}</td>
			<td><input type="checkbox" <eq name='vo._blank' value='1'>checked</eq> ></td>
			<td><a href="javascript:void(0);" class='edit' data-url='{:U("addfriend",array("id"=>$key))}'>编辑</a> <a href="#" onclick='del("{$key}")'>删除</a></td>
		</tr>
		</volist>
		<else/>
		<td colspan="7" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
</block>
<block name="script">
	<script type="text/javascript">
		function del(key){
			layer.confirm('您真的要删除吗' , function(e){
				var url = '__SELF__' + '?handle=del&id=' + key ; 
				$.post(url , function(data){
					if(data.status){
						layer.msg(data.info);
					}else{
						layer.msg(data.info);
					}
					layer.close(e);
					// setTimeout(function(){
					// 	window.location.reload();
					// },'2000');
				});
			})
		}

		$('.btn').on('click' , function(){
			var url = $(this).data('url');
			add(url);
		});

		//增加
		function add(url,id){
			//捕获页
			var url = url;
			layer.open({
			  type: 2, 
			  area: ['500px', '300px'],
			  content: url , 
			}); 

		}
		$('.edit').on('click' , function(){
			var url = $(this).data('url') ;
			add(url);
		});

	</script>
</block>